<script setup lang="ts">
import { reactive } from 'vue'
import {
  NForm,
  NFormItem,
  NInputNumber,
  NColorPicker,
  NScrollbar,
  NButton
} from 'naive-ui'
import SettingService from '@/services/setting.service'

const settingService = new SettingService()

const crossSetting = reactive({ ...settingService.crossConfig })

function onSave () {
  settingService.saveCorss(crossSetting)
}
</script>

<template>
  <div class="home">
    <n-scrollbar>
      <div class="region input">
        <!-- <span class="title">准星设置</span> -->
        <n-form label-width="60" label-placement="left" size="large">
          <n-form-item label="颜色" path="color">
            <n-color-picker v-model:value="crossSetting.color" :show-alpha="false" />
          </n-form-item>
          <n-form-item label="大小" path="size">
            <n-input-number :show-button="false" v-model:value="crossSetting.size" />
          </n-form-item>
          <n-form-item label="线宽" path="width">
            <n-input-number :show-button="false" v-model:value="crossSetting.width" />
          </n-form-item>
          <n-form-item label="间隔" path="gap">
            <n-input-number :show-button="false" v-model:value="crossSetting.gap" />
          </n-form-item>
          <n-form-item label="X偏移" path="offsetX">
            <n-input-number :show-button="false" v-model:value="crossSetting.offsetX" />
          </n-form-item>
          <n-form-item label="Y偏移" path="offsetY">
            <n-input-number :show-button="false" v-model:value="crossSetting.offsetY" />
          </n-form-item>
        </n-form>
      </div>
    </n-scrollbar>
    <div class="actions">
      <n-button type="primary" @click="onSave">保存</n-button>
    </div>
  </div>
</template>

<style scoped lang="less">
.home {
  width: 100vw;
  height: 100vh;
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  flex-direction: column;

  :deep(.n-scrollbar) {
    .n-scrollbar-content {
      display: flex;
      padding: 15px;
      padding-bottom: 0;
      .n-form-item-label__text {
        text-align-last: justify;
      }

      .region {
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-right: 15px;

        .title {
          font-size: 16px;
          font-weight: bold;
          padding: 0 0 12px 0;
          align-self: flex-start;
        }
        &:last-of-type {
          margin-right: 0;
        }
      }
    }
  }

  .actions {
    padding: 15px;
    box-shadow: 0 0 3px 0 #DDD;
    display: flex;
    justify-content: flex-end;
  }
}</style>
